package com.app.fenak;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.LinearLayout;
import android.widget.TextView;

public class PathsListAdapter extends BaseAdapter {

	// number of options on main options view
	private final int optionsCount; 
	private Context context;
	private String[] paths;
	
	public PathsListAdapter(Context context) {
		super();
		this.context = context;
		
		String[] tempPaths = context.getResources().getStringArray(R.array.options_titles);
		paths = tempPaths;
		optionsCount = tempPaths.length;
		
	}

	@Override
	public int getCount() {
		return optionsCount;
	}

	@Override
	public Object getItem(int pos) {
		return paths[pos];
	}

	@Override
	public long getItemId(int pos) {
		return R.layout.option_row_list;
	}

	@Override
	public View getView(int pos, View view, ViewGroup arg2) {
		
		view = (LinearLayout) view;
		
		if(view == null){
			 LayoutInflater vi = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
			 view = (LinearLayout) vi.inflate(R.layout.path_row, null, true);
		} 
		
		((TextView) view.findViewById(R.id.path_name)).setText(paths[pos]);
		
		return view;
	}

	class ViewHolder {
		int icon;
		String  title;
	}
}
